/**
 * @param {string[]} strs
 * @return {string[][]}
 */
var groupAnagrams = function (strs) {
    var result = {};
    strs.map(v => {
        let temp = v.split("").sort().join("");
        result[temp] ? result[temp].push(v) : result[temp] = [v];
    })
    var results = [];
    for (key in result) {
        results.push(result[key]);
    }
    return results;
};
// [ [ 'eat', 'tea', 'ate' ], [ 'tan', 'nat' ], [ 'bat' ] ]
console.log(groupAnagrams(["eat", "tea", "tan", "ate", "nat", "bat"]));